﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Rename.UC.组合
{
    public partial class Uc大小写转换 : UserControl
    {
        private EventHandler<CmbSelectChangeEventArgs> _cmbSelectChangeHandler = null;
        public Uc大小写转换()
        {
            InitializeComponent();
        }

        public event EventHandler<CmbSelectChangeEventArgs> CmbSelectChange
        {
            add { _cmbSelectChangeHandler += value; }
            remove { _cmbSelectChangeHandler -= value; }
        }

        protected virtual void OnCmbSelectChange(CmbSelectChangeEventArgs e)
        {
            EventHandler<CmbSelectChangeEventArgs> temp=System.Threading.Volatile.Read(ref _cmbSelectChangeHandler);
            if (temp != null)
            {
                temp(this, e);   
            }
        }

        private void Uc大小写转换_Load(object sender, EventArgs e)
        {
            ucCmb大小写转换.SelectedIndex = 0;
            ucCmb简繁体转换.SelectedIndex = 0;
            ucCmb中文转拼音.SelectedIndex = 0;
        }

        private void ucCmb大小写转换_SelectedIndexChanged(object sender, EventArgs e)
        {
            if(ucCmb大小写转换.Text=="不改变") OnCmbSelectChange(new CmbSelectChangeEventArgs() { CmbSelectType = CmbSelectType.大小写不改变 });
            else if (ucCmb大小写转换.Text == "首字母大写") OnCmbSelectChange(new CmbSelectChangeEventArgs() { CmbSelectType = CmbSelectType.大小写首字母大写 });
            else if (ucCmb大小写转换.Text == "首字母小写") OnCmbSelectChange(new CmbSelectChangeEventArgs() { CmbSelectType = CmbSelectType.大小写首字母小写 });
            else if (ucCmb大小写转换.Text == "全部大写") OnCmbSelectChange(new CmbSelectChangeEventArgs() { CmbSelectType = CmbSelectType.大小写全部大写 });
            else if (ucCmb大小写转换.Text == "全部小写") OnCmbSelectChange(new CmbSelectChangeEventArgs() { CmbSelectType = CmbSelectType.大小写全部小写 });
            else if (ucCmb大小写转换.Text == "单词首字母大写") OnCmbSelectChange(new CmbSelectChangeEventArgs() { CmbSelectType = CmbSelectType.大小写单词首字母大写 });
            else OnCmbSelectChange(new CmbSelectChangeEventArgs() { CmbSelectType = CmbSelectType.None });
        }

        private void ucCmb简繁体转换_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ucCmb简繁体转换.Text == "不改变") OnCmbSelectChange(new CmbSelectChangeEventArgs() { CmbSelectType = CmbSelectType.简繁体不改变 });
            else if (ucCmb简繁体转换.Text == "简体转繁体") OnCmbSelectChange(new CmbSelectChangeEventArgs() { CmbSelectType = CmbSelectType.简繁体简体转繁体 });
            else if (ucCmb简繁体转换.Text == "繁体转简体") OnCmbSelectChange(new CmbSelectChangeEventArgs() { CmbSelectType = CmbSelectType.简繁体繁体转简体 });
            else OnCmbSelectChange(new CmbSelectChangeEventArgs() { CmbSelectType = CmbSelectType.None });
        }

        private void ucCmb中文转拼音_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ucCmb中文转拼音.Text == "不改变") OnCmbSelectChange(new CmbSelectChangeEventArgs() { CmbSelectType = CmbSelectType.中文转拼音不改变 });
            else if (ucCmb中文转拼音.Text == "中文转拼音") OnCmbSelectChange(new CmbSelectChangeEventArgs() { CmbSelectType = CmbSelectType.中文转拼音 });
            else OnCmbSelectChange(new CmbSelectChangeEventArgs() { CmbSelectType = CmbSelectType.None });
        }
    }
}
